<?php
require_once 'Shared/Models/Ads.php';
require_once 'Shared/Models/AdsCategory.php';
require_once 'Shared/Models/Portal.php';
class adsSticker extends Vi_Sticker
{
	public function run()
	{
//		$portalId = Vi_Registry::getPortalId();
		$portalAlias = Vi_Registry::get('APP_NAME');
		$objPortal = new Models_Portal();
		$ortal = $objPortal->getPortalByAlias($portalAlias);
		$ortal = current($ortal);
		$params = $this->getParams(); // ads_category_id 
		$objAds = new Models_Ads();
		if (null ==@$params['size']) {
		    $params['size'] = 1;
		}
		if (null ==@$params['catId']) {
		    $params['catId'] = 0;
		}
		if (null ==@$params['portal_id']) {
		    $params['portal_id'] = 0;
		}
		$allAds = $objAds->getAdsbyAdsCategoryId($ortal['portal_id'], $params['catId'], $params['size']);
		$this->view->allAds = $allAds;
		$this->view->portalId = $ortal['portal_id'];
	}
}